{% extends 'subpage/base.html' %}
{% block table %}
    <div class="show-input-items clearfix">
        <table class="table table-bordered">
        </table>
    </div>
{% endblock %}
{% block return_block %}
    <div class="btn-return-back">
        <button class="btn btn-info" onclick="window.location.href='/secline'">返回</button>
    </div>
{% endblock %}
{% block ueditorbox %}
    <div class="main-richtext">

    </div>
    <script>
        $(function () {
            //获取地址栏参数
            var dutyId = GetQueryString('dutyId'), departId = GetQueryString('departId'), data = {},
                title = GetQueryString('departAlias');
            //动态标题
            var title = "<span class='duty_time'>" + GetQueryString("duty_time") + "</span>&nbsp;&nbsp;&nbsp;" + GetQueryString("departAlias") + "&nbsp;&nbsp;&nbsp;二线值班报告";//如果编辑状态的话应该放在ajax success回调的方法下
            $('.title-text').html(title);
            //判断返回的目的地
            if (parseInt(GetQueryString("isme"))) {
                $(".btn-return-back").html("<button class='btn btn-info' onclick=\"window.location.href='/mySecondlist'\">返回</button>");
            } else if (!parseInt(GetQueryString("isme"))) {
                $(".btn-return-back").html("<button class='btn btn-info' onclick=\"window.location.href='/secline'\">返回</button>");
            }
            if (dutyId && departId) {
                data.dutyId = dutyId;
                data.departId = departId;
                data.level = 2;
                function success(data) {
                    if (data.code !== 1) {//成功
                        var str = '';
                        //判断是系统运维部还是网络安全部
                        if (data.tableList.length > 0) {
                            if (data.tableList[0].idc) {//系统运维部
                                str += '<thead>' +
                                    '<tr>' +
                                    '<th style="width: 50%">机房位置</th>' +
                                    '<th>带宽值(Mb/s)</th>' +
                                    '</tr>' +
                                    '</thead><tbody>';
                                for (var i = 0; i < data.tableList.length; i++) {
                                    var item1 = data.tableList[i];
                                    str += '<tr><td>' + item1.idc + '</td><td>' + item1.bw + '</td></tr>';
                                }
                                str += '</tbody></table>';
                                $('.table').html(str);
                                $('.main-richtext').html(data.richText);
                            } else if (data.tableList[0].type && data.tableList[0].title) {//网络安全部
                                str += '<thead>' +
                                    '<tr>' +
                                    '<th>事件</th>' +
                                    '<th>类型</th>' +
                                    '<th>时间</th>' +
                                    '<th>说明</th>' +
                                    '</tr>' +
                                    '</thead><tbody>';
                                for (var i = 0; i < data.tableList.length; i++) {
                                    var item2 = data.tableList[i];
                                    str += '<tr><td>' + item2.title + '</td><td>' + item2.type + '</td><td>' + item2.ctime + '</td><td>' + item2.content + '</td></tr>';
                                }
                                str += '</tbody></table>';
                                $('.table').html(str);
                                $('.main-richtext').html(data.richText);
                            }
                        } else {
                            $('.main-richtext').html(data.richText);
                        }

                    } else {

                        $.myAlert({title: "出错提示", message: data.errmessage});
                    }


                }

                function error(err) {
                    $.myAlert({title: '出错提示', message: '请求出错!'});
                }

                ajaxRequest('GET', GLOBAL_VARIABLE.BASE_URL + '/datashow', data, success, error, '{{ csrf_token }}');
            }

        });
    </script>
{% endblock %}